import xlwt


def toExcel(_list):
    workbook = xlwt.Workbook(encoding='utf-8')
    worksheet = workbook.add_sheet('sheet1')
    for i in range(-1, len(_list)):
        column = 0
        if i == -1:
            for key in ['序号', '项目名称', '项目类型', '一级主管部门名称', '项目申报单位名称', '项目属性', '项目期', '项目实施责任人', '项目实施责任人联系电话', '年度资金总额',
                        '总体目标', '是否信息化项目']:
                worksheet.write(0, column, label=key)
                column = column + 1
        else:
            for key in ['id', 'name', 'type', 'department', 'company', 'property', 'ddl', 'person', 'tel', 'money',
                        'target', 'isInfo']:
                worksheet.write(i + 1, column, label=_list[i][key])
                column = column + 1
    workbook.save('./result/result.xls')
